//
//  BodyHeatController.m
//  Nurse
//
//  Created by Sunny on 14-1-20.
//  Copyright (c) 2014年 Honeywell. All rights reserved.
//

#import "BodyHeatController.h"
#import "SNLineChartView.h"
#import "NurseService.h"
#import "PatientService.h"

@interface BodyHeatController ()
@property(nonatomic,strong)NSString* pid;
@property(nonatomic,strong)NSArray* nr;


@end

@implementation BodyHeatController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
-(void)Setline
{
    
    
    //        LCLineChartData *d1x = [LCLineChartData new];
    //        {
    //            LCLineChartData *d1 = d1x;
    //            d1.xMin = 0;
    //            d1.xMax = 6;
    //            d1.title = @"The title for the legend";
    //            d1.color = MainGreenColor;o
    //
    //            d1.itemCount = 6;
    //
    //            d1.getData = ^(NSUInteger item) {
    //                float x = item;
    //                float y = (item+1);
    //                NSString *label1 = [NSString stringWithFormat:@"%d,item", item];
    //                NSString *label2 = [NSString stringWithFormat:@"%f,y", y];
    //                return [LCLineChartDataItem dataItemWithX:x y:y xLabel:label1 dataLabel:label2];
    //            };
    //        }
    
    
    
    if ([self.type isEqualToString:@"体温"]) {
        
        LCLineChartData *d2x = [LCLineChartData new];
        {
            
            [[NurseService sharedInstance]queryPatientsTWForPid:self.pid withSuccessHandler:^(id result) {
                
                if ([result isKindOfClass:[NSArray class]])
                {
                    LCLineChartData *d1 = d2x;
                    d1.xMin = 0;
                    d1.xMax = 12;
                    d1.title = @"体温";
                    d1.color = MainGreenColor;
                    
                    //[UIColor redColor];
                    d1.itemCount =[result count];
                    d1.getData = ^(NSUInteger item) {
                        float x = 2*item+1;
                        
                        id record = [result objectAtIndex:item];
                        //NSArray * twarr =[NSArray arrayWithObjects:@"37.2",@"38",@"37.5",@"40",@"39.2",nil];
                        NSString *tws=[record valueForKey:@"体温"];
                        NSString *rq=[record valueForKey:@"日期"];
                        NSString *sj=[record valueForKey:@"时间"];
                        
                        //[twarr objectAtIndex:item];
                        float tw=[tws floatValue];
                        //NSDictionary *d;
                        float y =((tw-35)/2)+1;
                        
                        NSString *label = [NSString stringWithFormat:@"%@", rq];
                        NSString *label1 = [NSString stringWithFormat:@"%@",sj];
                        //  NSString *label1 = [NSString stringWithFormat:@"%d", item];
                        NSString *label2 = [NSString stringWithFormat:@"%@℃",tws];
                        return [LCLineChartDataItem dataItemWithX:x y:y xLabel:label1 xLabel1:label  dataLabel:label2];
                    };
                    
                    
                    
                }
                
                
                LCLineChartView *chartView = [[LCLineChartView alloc] initWithFrame:CGRectMake(0, 160, 320, 330)];
                chartView.yMin = 0;
                chartView.yMax = 5;
                chartView.xMax=10;
                //chartView.xSteps = @[@"06:00",@"10:00",@"14:00",@"18:00",@"22:00"];
                chartView.ySteps = @[@"35",@"37",@"39",@"41",@"43"];
                
                //20，40，60，80，100，120，140，160，180 心率
                
                // 25 50 50 75 100 125 150 175 200 225 250 血压
                // 15 20 25 30 35 40 45 50  呼吸
                
                chartView.data = @[d2x];
                chartView.axisLabelColor = [UIColor blackColor];
                chartView.infoLblColor = MainGreenColor;
                chartView.currentPosColor = MainGreenColor;
                chartView.xAxisToBottom = 15;
                chartView.xAxisColor = [UIColor grayColor];
                chartView.xAxisLabelColor = [UIColor grayColor];
                [chartView showLegend:NO animated:YES];
                
                [self.view addSubview:chartView];
                
            } andFailHandler:^(NSError *error, NSString *title) {
                [[DataEngine sharedInstance]showMessage:[error description] withTitle:title];
            }];
            
        }
    }
    
    if ([self.type isEqualToString:@"呼吸"]) {
        
        LCLineChartData *d2x = [LCLineChartData new];
        {
            
            [[NurseService sharedInstance]queryPatientsHXForPid:self.pid withSuccessHandler:^(id result) {
                
                if ([result isKindOfClass:[NSArray class]])
                {
                    LCLineChartData *d1 = d2x;
                    d1.xMin = 0;
                    d1.xMax = 12;
                    d1.title = @"呼吸";
                    d1.color = MainGreenColor;
                    
                    //[UIColor redColor];
                    d1.itemCount =[result count];
                    d1.getData = ^(NSUInteger item) {
                        float x = 2*item+1;
                        
                        id record = [result objectAtIndex:item];
                        //NSArray * twarr =[NSArray arrayWithObjects:@"37.2",@"38",@"37.5",@"40",@"39.2",nil];
                        NSString *hxs=[record valueForKey:@"呼吸"];
                        NSString *rq=[record valueForKey:@"日期"];
                        NSString *sj=[record valueForKey:@"时间"];
                        
                        //[twarr objectAtIndex:item];
                        float hx=[hxs floatValue];
                        //NSDictionary *d;
                        float y =((hx-15)/5)+1;
                        
                        NSString *label = [NSString stringWithFormat:@"%@", rq];
                        NSString *label1 = [NSString stringWithFormat:@"%@",sj];
                        //  NSString *label1 = [NSString stringWithFormat:@"%d", item];
                        NSString *label2 = [NSString stringWithFormat:@"%@次/分",hxs];
                        return [LCLineChartDataItem dataItemWithX:x y:y xLabel:label1 xLabel1:label  dataLabel:label2];
                    };
                    
                    
                    
                }
                
                
                LCLineChartView *chartView = [[LCLineChartView alloc] initWithFrame:CGRectMake(0, 160, 320, 330)];
                chartView.yMin = 0;
                chartView.yMax = 8;
                chartView.xMax=10;
                //chartView.xSteps = @[@"06:00",@"10:00",@"14:00",@"18:00",@"22:00"];
                chartView.ySteps = @[@"15",@"20",@"25",@"30",@"35",@"40",@"45",@"50"];
                
                //20，40，60，80，100，120，140，160，180 心率
                
                // 25 50 50 75 100 125 150 175 200 225 250 血压
                // 15 20 25 30 35 40 45 50  呼吸
                
                chartView.data = @[d2x];
                chartView.axisLabelColor = [UIColor blackColor];
                chartView.infoLblColor = MainGreenColor;
                chartView.currentPosColor = MainGreenColor;
                chartView.xAxisToBottom = 15;
                chartView.xAxisColor = [UIColor grayColor];
                chartView.xAxisLabelColor = [UIColor grayColor];
                [chartView showLegend:NO animated:YES];
                
                [self.view addSubview:chartView];
                
            } andFailHandler:^(NSError *error, NSString *title) {
                [[DataEngine sharedInstance]showMessage:[error description] withTitle:title];
            }];
            
        }
    }
    if ([self.type isEqualToString:@"脉搏"]) {
        
        LCLineChartData *d2x = [LCLineChartData new];
        {
            
            [[NurseService sharedInstance]queryPatientsMBForPid:self.pid withSuccessHandler:^(id result) {
                
                if ([result isKindOfClass:[NSArray class]])
                {
                    LCLineChartData *d1 = d2x;
                    d1.xMin = 0;
                    d1.xMax = 12;
                    d1.title = @"脉搏";
                    d1.color = MainGreenColor;
                    
                    //[UIColor redColor];
                    d1.itemCount =[result count];
                    d1.getData = ^(NSUInteger item) {
                        float x = 2*item+1;
                        
                        id record = [result objectAtIndex:item];
                        //NSArray * twarr =[NSArray arrayWithObjects:@"37.2",@"38",@"37.5",@"40",@"39.2",nil];
                        NSString *mbs=[record valueForKey:@"脉搏"];
                        NSString *rq=[record valueForKey:@"日期"];
                        NSString *sj=[record valueForKey:@"时间"];
                        
                        //[twarr objectAtIndex:item];
                        float mb=[mbs floatValue];
                        //NSDictionary *d;
                        float y =((mb-20)/20)+1;
                        
                        NSString *label = [NSString stringWithFormat:@"%@", rq];
                        NSString *label1 = [NSString stringWithFormat:@"%@",sj];
                        //  NSString *label1 = [NSString stringWithFormat:@"%d", item];
                        NSString *label2 = [NSString stringWithFormat:@"%@次/分",mbs];
                        return [LCLineChartDataItem dataItemWithX:x y:y xLabel:label1 xLabel1:label  dataLabel:label2];
                    };
                    
                    
                    
                }
                
                
                LCLineChartView *chartView = [[LCLineChartView alloc] initWithFrame:CGRectMake(0, 160, 320, 330)];
                chartView.yMin = 0;
                chartView.yMax = 9;
                chartView.xMax=10;
                //chartView.xSteps = @[@"06:00",@"10:00",@"14:00",@"18:00",@"22:00"];
                chartView.ySteps = @[@"20",@"40",@"60",@"80",@"100",@"120",@"140",@"160",@"180"];
                
                //20，40，60，80，100，120，140，160，180 心率
                
                // 25 50 50 75 100 125 150 175 200 225 250 血压
                // 15 20 25 30 35 40 45 50  呼吸
                
                chartView.data = @[d2x];
                chartView.axisLabelColor = [UIColor blackColor];
                chartView.infoLblColor = MainGreenColor;
                chartView.currentPosColor = MainGreenColor;
                chartView.xAxisToBottom = 15;
                chartView.xAxisColor = [UIColor grayColor];
                chartView.xAxisLabelColor = [UIColor grayColor];
                [chartView showLegend:NO animated:YES];
                
                [self.view addSubview:chartView];
                
            } andFailHandler:^(NSError *error, NSString *title) {
                [[DataEngine sharedInstance]showMessage:[error description] withTitle:title];
            }];
            
        }
    }
    if ([self.type isEqualToString:@"心率"]) {
        
        LCLineChartData *d2x = [LCLineChartData new];
        {
            
            [[NurseService sharedInstance]queryPatientsXLForPid:self.pid withSuccessHandler:^(id result) {
                
                if ([result isKindOfClass:[NSArray class]])
                {
                    LCLineChartData *d1 = d2x;
                    d1.xMin = 0;
                    d1.xMax = 12;
                    d1.title = @"心率";
                    d1.color = MainGreenColor;
                    
                    //[UIColor redColor];
                    d1.itemCount =[result count];
                    d1.getData = ^(NSUInteger item) {
                        float x = 2*item+1;
                        
                        id record = [result objectAtIndex:item];
                        //NSArray * twarr =[NSArray arrayWithObjects:@"37.2",@"38",@"37.5",@"40",@"39.2",nil];
                        NSString *xls=[record valueForKey:@"心率"];
                        NSString *rq=[record valueForKey:@"日期"];
                        NSString *sj=[record valueForKey:@"时间"];
                        
                        //[twarr objectAtIndex:item];
                        float xl=[xls floatValue];
                        //NSDictionary *d;
                        float y =((xl-20)/20)+1;
                        
                        NSString *label = [NSString stringWithFormat:@"%@", rq];
                        NSString *label1 = [NSString stringWithFormat:@"%@",sj];
                        //  NSString *label1 = [NSString stringWithFormat:@"%d", item];
                        NSString *label2 = [NSString stringWithFormat:@"%@次/分",xls];
                        return [LCLineChartDataItem dataItemWithX:x y:y xLabel:label1 xLabel1:label  dataLabel:label2];
                    };
                    
                    
                    
                }
                
                
                LCLineChartView *chartView = [[LCLineChartView alloc] initWithFrame:CGRectMake(0, 160, 320, 330)];
                chartView.yMin = 0;
                chartView.yMax = 9;
                chartView.xMax=10;
                //chartView.xSteps = @[@"06:00",@"10:00",@"14:00",@"18:00",@"22:00"];
                chartView.ySteps = @[@"20",@"40",@"60",@"80",@"100",@"120",@"140",@"160",@"180"];
                
                //20，40，60，80，100，120，140，160，180 心率
                
                // 25 50 50 75 100 125 150 175 200 225 250 血压
                // 15 20 25 30 35 40 45 50  呼吸
                
                chartView.data = @[d2x];
                chartView.axisLabelColor = [UIColor blackColor];
                chartView.infoLblColor = MainGreenColor;
                chartView.currentPosColor = MainGreenColor;
                chartView.xAxisToBottom = 15;
                chartView.xAxisColor = [UIColor grayColor];
                chartView.xAxisLabelColor = [UIColor grayColor];
                [chartView showLegend:NO animated:YES];
                
                [self.view addSubview:chartView];
                
            } andFailHandler:^(NSError *error, NSString *title) {
                [[DataEngine sharedInstance]showMessage:[error description] withTitle:title];
            }];
            
        }
    }
    
    //    if ([self.type isEqualToString:@"血压"]) {
    //
    //        {
    //        LCLineChartData *d1x = [LCLineChartData new];
    //        {
    //
    //            [[NurseService sharedInstance]queryPatientsXYForPid:self.pid withSuccessHandler:^(id result) {
    //
    //                if ([result isKindOfClass:[NSArray class]])
    //                {
    //                    LCLineChartData *d1 = d1x;
    //                    d1.xMin = 0;
    //                    d1.xMax = 12;
    //                    d1.title = @"The title for the legend";
    //                    d1.color = MainGreenColor;//[UIColor redColor];
    //                    //[UIColor redColor];
    //                    d1.itemCount =[result count];
    //                    d1.getData = ^(NSUInteger item) {
    //                        float x = 2*item+1;
    //
    //                        id record = [result objectAtIndex:item];
    //                        //NSArray * twarr =[NSArray arrayWithObjects:@"37.2",@"38",@"37.5",@"40",@"39.2",nil];
    //                        NSString *xygs=[record valueForKey:@"血压高"];
    //                        NSString *rq=[record valueForKey:@"日期"];
    //                        NSString *sj=[record valueForKey:@"时间"];
    //
    //                        //[twarr objectAtIndex:item];
    //                        float xyg=[xygs floatValue];
    //                        //NSDictionary *d;
    //                        float y =((xyg-25)/25)+1;
    //
    //                        NSString *label = [NSString stringWithFormat:@"%@", rq];
    //                        NSString *label1 = [NSString stringWithFormat:@"%@",sj];
    //                        //  NSString *label1 = [NSString stringWithFormat:@"%d", item];
    //                        NSString *label2 = [NSString stringWithFormat:@"%@mmHg",xygs];
    //                        return [LCLineChartDataItem dataItemWithX:x y:y xLabel:label1 xLabel1:label  dataLabel:label2];
    //                    };
    //
    //
    //
    //                }
    //
    //
    //
    //            } andFailHandler:^(NSError *error, NSString *title) {
    //                [[DataEngine sharedInstance]showMessage:[error description] withTitle:title];
    //            }];
    //
    //        }
    //
    //        LCLineChartData *d2x = [LCLineChartData new];
    //        {
    //
    //            [[NurseService sharedInstance]queryPatientsXYForPid:self.pid withSuccessHandler:^(id result) {
    //
    //                if ([result isKindOfClass:[NSArray class]])
    //                {
    //                    LCLineChartData *d1 = d2x;
    //                    d1.xMin = 0;
    //                    d1.xMax = 12;
    //                    d1.title = @"The title for the legend";
    //                    d1.color = MainGreenColor;
    //
    //                    //[UIColor redColor];
    //                    d1.itemCount =[result count];
    //                    d1.getData = ^(NSUInteger item) {
    //                        float x = 2*item+1;
    //
    //                        id record = [result objectAtIndex:item];
    //                        //NSArray * twarr =[NSArray arrayWithObjects:@"37.2",@"38",@"37.5",@"40",@"39.2",nil];
    //                        NSString *xyds=[record valueForKey:@"血压低"];
    //                        NSString *rq=[record valueForKey:@"日期"];
    //                        NSString *sj=[record valueForKey:@"时间"];
    //
    //                        //[twarr objectAtIndex:item];
    //                        float xyd=[xyds floatValue];
    //                        //NSDictionary *d;
    //                        float y =((xyd-25)/25)+1;
    //
    //                        NSString *label = [NSString stringWithFormat:@"%@", rq];
    //                        NSString *label1 = [NSString stringWithFormat:@"%@",sj];
    //                        //  NSString *label1 = [NSString stringWithFormat:@"%d", item];
    //                        NSString *label2 = [NSString stringWithFormat:@"%@mmHg",xyds];
    //                        return [LCLineChartDataItem dataItemWithX:x y:y xLabel:label1 xLabel1:label  dataLabel:label2];
    //                    };
    //
    //
    //
    //                }
    //
    //
    ////                LCLineChartView *chartView = [[LCLineChartView alloc] initWithFrame:CGRectMake(0, 160, 320, 330)];
    ////                chartView.yMin = 0;
    ////                chartView.yMax = 10;
    ////                chartView.xMax=10;
    ////                //chartView.xSteps = @[@"06:00",@"10:00",@"14:00",@"18:00",@"22:00"];
    ////                chartView.ySteps = @[@"25",@"50",@"75",@"100",@"125",@"150",@"175",@"200",@"225",@"250"];
    ////
    ////                //20，40，60，80，100，120，140，160，180 心率
    ////
    ////                // 25 50 50 75 100 125 150 175 200 225 250 血压
    ////                // 15 20 25 30 35 40 45 50  呼吸
    ////
    ////                chartView.data = @[d2x];
    ////                chartView.axisLabelColor = [UIColor blackColor];
    ////                chartView.infoLblColor = MainGreenColor;
    ////                chartView.currentPosColor = MainGreenColor;
    ////                chartView.xAxisToBottom = 15;
    ////                chartView.xAxisColor = [UIColor grayColor];
    ////                chartView.xAxisLabelColor = [UIColor grayColor];
    ////                [chartView showLegend:NO animated:YES];
    ////
    ////                 [self.view addSubview:chartView];
    //
    //            } andFailHandler:^(NSError *error, NSString *title) {
    //                [[DataEngine sharedInstance]showMessage:[error description] withTitle:title];
    //            }];
    //
    //        }
    //
    //        LCLineChartView *chartView = [[LCLineChartView alloc] initWithFrame:CGRectMake(0, 160, 320, 330)];
    //        chartView.yMin = 0;
    //        chartView.yMax = 10;
    //        chartView.xMax=10;
    //        //chartView.xSteps = @[@"06:00",@"10:00",@"14:00",@"18:00",@"22:00"];
    //        chartView.ySteps = @[@"25",@"50",@"75",@"100",@"125",@"150",@"175",@"200",@"225",@"250"];
    //
    //        //20，40，60，80，100，120，140，160，180 心率
    //
    //        // 25 50 50 75 100 125 150 175 200 225 250 血压
    //        // 15 20 25 30 35 40 45 50  呼吸
    //
    //        chartView.data = @[d1x,d2x];
    //        chartView.axisLabelColor = [UIColor blackColor];
    //        chartView.infoLblColor = MainGreenColor;
    //        chartView.currentPosColor = MainGreenColor;
    //        chartView.xAxisToBottom = 15;
    //        chartView.xAxisColor = [UIColor grayColor];
    //        chartView.xAxisLabelColor = [UIColor grayColor];
    //        [chartView showLegend:NO animated:YES];
    //
    //        [self.view addSubview:chartView];
    //        }
    //    }
    if ([self.type isEqualToString:@"血压"]) {
        
        {
            LCLineChartData *d1x = [LCLineChartData new];
            LCLineChartData *d2x = [LCLineChartData new];
            LCLineChartView *chart = nil;
            {
                
                [[NurseService sharedInstance]queryPatientsXYForPid:self.pid withSuccessHandler:^(id result) {
                    
                    if ([result isKindOfClass:[NSArray class]])
                    {
                        LCLineChartData *d1 = d1x;
                        d1.xMin = 0;
                        d1.xMax = 12;
                        d1.title = @"xyg";
                        d1.color =[UIColor redColor];
                        //MainGreenColor;
                        
                        d1.itemCount =[result count];
                        d1.getData = ^(NSUInteger item) {
                            float x = 2*item+1;
                            
                            id record = [result objectAtIndex:item];
                            //NSArray * twarr =[NSArray arrayWithObjects:@"37.2",@"38",@"37.5",@"40",@"39.2",nil];
                            NSString*xyds=[record valueForKey:@"血压低"];
                            NSString*rq=[record valueForKey:@"日期"];
                            NSString*sj=[record valueForKey:@"时间"];
                            
                            //[twarr objectAtIndex:item];
                            float xyd=[xyds floatValue];
                            //NSDictionary *d;
                            float y =((xyd-25)/25)+1;
                            
                            NSString *label = [NSString stringWithFormat:@"%@", rq];
                            NSString *label1 = [NSString stringWithFormat:@"%@",sj];
                            //  NSString *label1 = [NSString stringWithFormat:@"%d", item];
                            NSString *label2 = [NSString stringWithFormat:@"%@mmHg",xyds];
                            return [LCLineChartDataItem dataItemWithX:x y:y xLabel:label1 xLabel1:label  dataLabel:label2];
                        };
                    }
                    NSMutableArray *muarr = [[NSMutableArray alloc] init];
                    if (d1x.itemCount>0) {
                        [muarr addObject:d1x];
                        
                    }
                    
                    if (d2x.itemCount > 0) {
                        [muarr addObject:d2x];
                    }
                    
                    chart.data =muarr ;
                    
                } andFailHandler:^(NSError *error, NSString *title) {
                    [[DataEngine sharedInstance]showMessage:[error description] withTitle:title];
                }];
                
            }
            
            
            {
                
                [[NurseService sharedInstance]queryPatientsXYForPid:self.pid withSuccessHandler:^(id result) {
                    
                    if ([result isKindOfClass:[NSArray class]])
                    {
                        LCLineChartData *d1 = d2x;
                        d1.xMin = 0;
                        d1.xMax = 12;
                        d1.title = @"xyd";
                        d1.color =MainGreenColor;
                        //[UIColor redColor];
                        d1.itemCount =[result count];
                        d1.getData = ^(NSUInteger item) {
                            float x = 2*item+1;
                            
                            id record = [result objectAtIndex:item];
                            //NSArray * twarr =[NSArray arrayWithObjects:@"37.2",@"38",@"37.5",@"40",@"39.2",nil];
                            NSString *xygs=[record valueForKey:@"血压高"];
                            NSString *rq=[record valueForKey:@"日期"];
                            NSString *sj=[record valueForKey:@"时间"];
                            
                            //[twarr objectAtIndex:item];
                            float xyg=[xygs floatValue];
                            //NSDictionary *d;
                            float y =((xyg-25)/25)+1;
                            
                            NSString *label = [NSString stringWithFormat:@"%@", rq];
                            NSString *label1 = [NSString stringWithFormat:@"%@",sj];
                            //  NSString *label1 = [NSString stringWithFormat:@"%d", item];
                            NSString *label2 = [NSString stringWithFormat:@"%@mmHg",xygs];
                            return [LCLineChartDataItem dataItemWithX:x y:y xLabel:label1 xLabel1:label  dataLabel:label2];
                        };
                    }
                    NSMutableArray *muarr = [[NSMutableArray alloc] init];
                    if (d1x.itemCount>0) {
                        [muarr addObject:d1x];
                        
                    }
                    
                    if (d2x.itemCount > 0) {
                        [muarr addObject:d2x];
                    }
                    
                    chart.data =muarr ;
                    LCLineChartView *chartView = [[LCLineChartView alloc] initWithFrame:CGRectMake(0, 160, 320, 330)];
                    chartView.yMin = 0;
                    chartView.yMax = 10;
                    chartView.xMax=10;
                    //chartView.xSteps = @[@"06:00",@"10:00",@"14:00",@"18:00",@"22:00"];
                    chartView.ySteps = @[@"25",@"50",@"75",@"100",@"125",@"150",@"175",@"200",@"225",@"250"];
                    
                    //20，40，60，80，100，120，140，160，180 心率
                    
                    // 25 50 50 75 100 125 150 175 200 225 250 血压
                    // 15 20 25 30 35 40 45 50  呼吸
                    
                    chartView.data =muarr;
                    chartView.axisLabelColor = [UIColor blackColor];
                    chartView.infoLblColor = MainGreenColor;
                    chartView.currentPosColor = MainGreenColor;
                    chartView.xAxisToBottom = 15;
                    chartView.xAxisColor = [UIColor grayColor];
                    chartView.xAxisLabelColor = [UIColor grayColor];
                    [chartView showLegend:NO animated:YES];
                    //chart = chartView;
                    [self.view addSubview:chartView];
                    
                    
                } andFailHandler:^(NSError *error, NSString *title) {
                    [[DataEngine sharedInstance]showMessage:[error description] withTitle:title];
                }];
                
            }
            
            
        }
    }
    
    
    
    
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    //self.title = @"体征-体温";
    if ([self.type isEqualToString:@"体温"]) {
        self.title = @"体征-体温";
        self.Imagelx.image=[UIImage imageNamed:@"tizheng-wendu.png"];
        self.lblname.text=@"体温";
        self.lbldw.text=@"℃";
        
    }
    
    if ([self.type isEqualToString:@"呼吸"]) {
        self.title = @"体征-呼吸";
        self.Imagelx.image=[UIImage imageNamed:@"tizheng-huxi.png"];
        self.lblname.text=@"呼吸";
        self.lbldw.text=@"次/分";
        
    }
    if ([self.type isEqualToString:@"脉搏"]) {
        self.title = @"体征-脉搏";
        self.Imagelx.image=[UIImage imageNamed:@"tizheng-maibo.png"];
        self.lblname.text=@"脉搏";
        self.lbldw.text=@"次/分";
        
    }
    
    if ([self.type isEqualToString:@"心率"]) {
        self.title = @"体征-心率";
        self.Imagelx.image=[UIImage imageNamed:@"tizheng-xinlv.png"];
        self.lblname.text=@"心率";
        self.lbldw.text=@"次/分";
        
    }
    if ([self.type isEqualToString:@"血压"]) {
        self.title = @"体征-血压";
        self.Imagelx.image=[UIImage imageNamed:@"tizheng-xueya.png"];
        self.lblname.text=@"血压";
        self.lbldw.text=@"mmHg";
        
    }
    
    
    self.Imagelx.contentMode = UIViewContentModeScaleAspectFit;
    
    NSDictionary* patient = [[PatientService sharedInstance]currentPatient];
    
    // [[PatientService sharedInstance]currentPatient]=@"123456";
    self.pid=[patient valueForKey:@"住院号"];
    self.pInfoView.txtPatientName.text = [patient valueForKey:@"姓名"];
    self.pInfoView.txtPatientID.text = [NSString stringWithFormat:@"住院号:%@",[patient valueForKey:@"住院号"]];
    self.pInfoView.txtBedNo.text = [NSString stringWithFormat:@"床位号:%@",[patient valueForKey:@"床位号"]];
    NSString*xb= [patient valueForKey:@"性别"];
    if ([xb isEqualToString:@"女"]) {
        self.pInfoView.imgxb.image=[UIImage imageNamed:@"gender-female2.png"];
        
    }
    else{
        self.pInfoView.imgxb.image=[UIImage imageNamed:@"gender-male2.png"];
    }
    
    //设置图形样式及传递数据。
    [self Setline];
    
    
    
    
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
